package app.netant.book.xinguli;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class XinguliDetail extends BaseDetail {

	public XinguliDetail(String netSite) {
		super(netSite);
		this.preHref = "http://www.xinguli.com";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select("#main #bookdetail #info .infotitle h1 a");
		if(parts.size()>0){
			String title = parts.get(0).text();
			int idx = title.indexOf("txt");
			if(idx>0){
				title = title.substring(0,idx);
			}
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".zip");
		}
	}

	@Override
	public void analyseTags() {
		
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select("#main #bookdetail #info #aboutbook");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select("#main #mainleft #downbox ul li a");
		for(int i=0;i<parts.size();i++){
			String text = parts.get(i).text();
			if(text.indexOf("zip下载")>0){
				String href = parts.get(i).attr("href");
				if(href.startsWith("/")){
					href = this.preHref + href;
				}
				System.out.println("【Href】:"+href);
				this.entity.setDownPath(href);
				break;
			}
		}
	}
	
	@Override
	public void analyseType() {
		Elements parts = this.select("#main #bookdetail #picbox .imgtip");
		if(parts.size()>0){
			String type = parts.get(0).text();
			int idx = type.indexOf("/");
			if(idx>0){
				type = type.substring(0,idx).trim();
			}
			System.out.println("【Type】:"+type);
			this.entity.setNovelType(type);
		}
	}
	
	public static void main(String[] args) {
		XinguliDetail detail = new XinguliDetail("http://www.xinguli.com/59561/down/");
		detail.test();
	}



}
